home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-06-19 | 3.7 KB | 109 lines | [TEXT/KAHL] |
- /******************************************************************************
- CAMPopupMenu.c
-
-
- Used in order to provide font, size and style to popup menus.
-
- SUPERCLASS = CPopupMenu
-
- Copyright © 1991 Bowers Development Corporation. All rights reserved.
-
- ******************************************************************************/
-
- #include <CBartender.h>
- #include <TBUtilities.h>
- #include <Global.h>
- #include "CAMPopupMenu.h"
-
- /* used by CAMPopupMenu::IAMPopupMenu: */
- extern CBartender *gBartender;
-
- /* used by ChangeSystemFont & CAMPopupMenu::PopupSelect: */
- #define SysFontFamPtr ((short *) 0x0BA6)
- #define SysFontSizePtr ((short *) 0x0BA8)
- #define LastSpExtraPtr ((long *) 0x0B4C)
-
- /******************************************************************************
- IAMPopupMenu
-
- Initialize an AppMaker popup menu.
- Saves font and size in instance variables for PopupSelect,
- then initializes its superclass.
- Sets the DimOption so that all items in the popup will be enabled.
- Since only the System Font has a checkmark symbol,
- it turns off checking for all other fonts.
-
- ******************************************************************************/
- void CAMPopupMenu::IAMPopupMenu (short aMenuID,
- CBureaucrat *aSupervisor,
- Boolean fAutoSelect,
- Boolean fMultiSelect,
- short aFontNum,
- short aFontSize)
- {
- theFontNum = aFontNum;
- theTextSize = aFontSize;
-
- CPopupMenu::IPopupMenu (aMenuID, aSupervisor, fAutoSelect, fMultiSelect);
- gBartender->SetDimOption (aMenuID, dimNONE);
- if (theFontNum != systemFont) {
- gBartender->SetUnchecking (menuID, TRUE);
- /* only systemFont has a check mark */
- }
- } /* IAMPopupMenu */
-
- /*----------*/
- /* This procedure changes the system font and size.
- */
- /*----------*/
- static void ChangeSystemFont(short fontNum, short fontSize);
- static void ChangeSystemFont(short fontNum, short fontSize)
- {
- if ((*SysFontFamPtr != fontNum) || (*SysFontSizePtr != fontSize)) {
- *SysFontFamPtr = fontNum;
- *SysFontSizePtr = fontSize;
- *LastSpExtraPtr = -1L; /* tells Font Manager to flush & reload font cache */
- } /* otherwise, *SysFontFamPtr == fontNum && *SysFontSizePtr == fontSize, do nothing */
- } /* ChangeSystemFont */
-
- /******************************************************************************
- PopupSelect {OVERRIDE}
-
- Save the port information, set font/size/style from instance variables
- for this object, call inherited, then reset the port.
-
- ******************************************************************************/
- long CAMPopupMenu::PopupSelect (Point where,
- long aCmd)
- {
- short saveSysFontFam;
- short saveSysFontSize;
- long returnedCmd;
-
- /* save old values of low-memory globals: */
- saveSysFontFam = *SysFontFamPtr;
- saveSysFontSize = *SysFontSizePtr;
-
- /* set the font information from instance variables: */
- ChangeSystemFont(theFontNum, theTextSize);
-
- returnedCmd = inherited::PopupSelect (where, aCmd);
-
- /* set the font information back to saved variables: */
- ChangeSystemFont(saveSysFontFam, saveSysFontSize);
-
- /* inherited::PopupSelect called InsertMenu/PopUpMenuSelect/DeleteMenu. DeleteMenu */
- /* recalculated the widths of the titles in the main menu bar using the system */
- /* font that we set for the pop-up, so to avoid having the user's menu bar draw */
- /* strangely, we need to call DeleteMenu again here (preceded by InsertMenu) */
- /* to recalculate again using the correct system font: */
- if ((saveSysFontFam != theFontNum) || (saveSysFontSize != theTextSize)) {
- InsertMenu (macMenu, hierMenu); /* temporarily insert into menu list */
- DeleteMenu (menuID); /* remove from menu list (recalculates menu widths) */
- }
-
- return (returnedCmd);
- } /* PopupSelect */
-
- /* CAMPopupMenu */
-